package com.lx.spring.mapper;


import com.lx.spring.biz.UserBiz;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Repository
@Lazy
@Scope("prototype")
@Primary
@Data
public class UserMapper {

    private String name = "张三";

    /*@Autowired
    private UserBiz userBiz;*/

    /*public UserMapper() {
        System.out.println("UserMapper constructor" + name);
    }*/

    //构造函数之后执行的方法
    @PostConstruct
    public void init(){
        //构造函数 是java对象的初始化, jvm的初始化
        // @PostConstruct Spring的初始化，
        //会在内部属性完成 Spring 注入之后再执行

        System.out.println("========= UserMapper.init================" + name);
    }

    @PreDestroy
    public void finish(){
        System.out.println("========= UserMapper.finish==============" + name) ;
    }

    public void login(String name, String pwd){
        System.out.println("========= UserMapper.login==============" + name);
    }

    public String reg(){
        System.out.println("========= UserMapper.reg==============" + name);
        return "注册成功";
    }

    public void query(){
        Object o = 100;
        String s = (String) o;
        System.out.println("s = " + s);
        System.out.println("========= UserMapper.query==============" + name);
    }
}
